<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let s = "name=张三age=20sex=男";
			let s1 = "name:张三,age:20,sex:男";
			//json格式的字符串
			let j1 = '{"name": "张三","age": 20,"sex": "男"}';

			// console.log(j1.name);

			const obj = {
				name: "张三",
				age: 20,
				sex: "男"
			}
			//--------------JSON字符串转对象------------------------------------------
			const o1 = JSON.parse(j1);
			// console.log(o1.name);
			//--------------对象转JSON字符串------------------------------------------
			let s2 = JSON.stringify(obj);
			// console.log(s2, typeof s2);


			let s3 = '{"code":200,"message":"成功!","result":{"name":"寻常百种花齐发，偏摘梨花与白人。","from":"元稹《离思五首》"}}';
			const o3 = JSON.parse(s3);
			// console.log(o3.result.name);

			let s4 = '[{"name":"张三","age":20,"sex":"男"},{"name":"李四","age":30,"sex":"女"}]';
			const o4 = JSON.parse(s4);
			console.log(o4[0].name);
		</script>
	</head>
	<body>
	</body>
</html>
